﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Text.RegularExpressions;

public partial class ManSc : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["group"] == null)
        {
            Response.Redirect("../Login.aspx");
        }
        else if ((int)Session["group"] != 3)
        {
            Response.Redirect("../Login.aspx");
        }
        SqlConnection sqlcon = null;
        SqlCommand sqlcmd = null;
        string cmd = "";
        sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["testLottery"].ConnectionString);
        sqlcon.Open();
        cmd = "select id,name from Area;";
        sqlcmd = new SqlCommand(cmd, sqlcon);
        SqlDataAdapter da = new SqlDataAdapter(cmd, sqlcon);
        DataSet ds = new DataSet();
        da.Fill(ds, "anyway");
        if (!IsPostBack)
        {
            DropDownList1.DataSource = ds.Tables["anyway"].DefaultView;
            DropDownList1.DataTextField = "name";
            DropDownList1.DataValueField = "id";
            DropDownList1.DataBind();
        }
        sqlcon.Close();
        SqlDataSource1.SelectCommand = "select id,address,score,stime from Node where area=" + DropDownList1.SelectedValue + ";";
        GridView1.DataBind();
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        SqlDataSource1.SelectCommand = "select id,address,score,stime from Node where area=" + DropDownList1.SelectedValue + ";";
        GridView1.DataBind();

    }
}